import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:huajianshe_app/base/BaseState.dart';
import 'package:huajianshe_app/common/res.dart';
import 'package:huajianshe_app/pages/lesson/LessonListPage.dart';
import 'package:huajianshe_app/widget/RoundedCornerWidget.dart';
import 'package:huajianshe_app/widget/RoundedUnderlineTabIndicator.dart';
import 'package:huajianshe_app/widget/appbar/CAppBar.dart';

class MyLessonsPage extends StatefulWidget {

  // final MyLessonType type;
  //
  // const MyLessonsPage(this.type, {Key? key}) : super(key: key);

  @override
  State<StatefulWidget> createState() {
    return _MyLessonsPageState();
  }
}

class _MyLessonsPageState extends BaseState<MyLessonsPage> with SingleTickerProviderStateMixin  {

  late TabController tabController;

  @override
  void initState() {
    super.initState();
    tabController = TabController(length: 2, vsync: this);
  }
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.white,
      appBar: CAppBar(title: '我的课程', overlayStyle: SystemUiOverlayStyle.dark),
      body: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
        RoundedCornerWidget(child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
          H(8),
          Padding(padding: EdgeInsets.only(left: 8, top: 2),
              child: TabBar(
                  labelPadding: EdgeInsets.only(left: 6, right: 24, bottom: 6),
                  indicatorWeight: 0,
                  indicatorSize: TabBarIndicatorSize.label,
                  indicator: RoundedUnderlineTabIndicator(
                    insets: EdgeInsets.only(left: -8, right: 8, top: 0, bottom: -5),
                    borderSide: BorderSide(width: 1, color: C.primary),
                  ),
                  isScrollable: true,
                  controller: tabController,
                  labelColor: C.gray333,
                  unselectedLabelColor: C.gray999,
                  labelStyle: TS(15, C.gray333, fontWeight: FontWeight.bold),
                  unselectedLabelStyle: TS(15, C.gray999),
                  tabs: [Text('我购买的'), Text('我收藏的')]
              )
          ),
          H(5),
          D(),
        ]), backgroundColor: Colors.white, radius: 0, cornerPosition: 0, height: 44, width: double.infinity,
          padding: EdgeInsets.symmetric(horizontal: 0)
        ),
        Expanded(child: TabBarView(controller: tabController, children: [
          LessonListPage(MyLessonType.buy),
          LessonListPage(MyLessonType.favorite),
        ]))
      ]),
    );
  }
}